import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
var _excluded = ["children", "statistic", "className", "chart", "chartPlacement", "footer"];
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { ConfigProvider } from 'antd-v4';
import classNames from 'classnames';
import { useContext } from 'react';
import Card from '../Card';
import Divider from '../Divider';
import Operation from '../Operation';
import Statistic from '../Statistic';
import './index.less';

var StatisticCard = function StatisticCard(props) {
  var _classNames;

  var children = props.children,
      statistic = props.statistic,
      className = props.className,
      chart = props.chart,
      chartPlacement = props.chartPlacement,
      footer = props.footer,
      others = _objectWithoutProperties(props, _excluded);

  var _useContext = useContext(ConfigProvider.ConfigContext),
      getPrefixCls = _useContext.getPrefixCls;

  var prefixCls = getPrefixCls('pro-statistic-card');
  var classString = classNames(prefixCls, className); // 在 StatisticCard 中时默认为 vertical。

  var statisticDom = statistic && _jsx(Statistic, _objectSpread({
    layout: "vertical"
  }, statistic));

  var chartCls = classNames("".concat(prefixCls, "-chart"), (_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-chart-left"), chartPlacement === 'left' && chart && statistic), _defineProperty(_classNames, "".concat(prefixCls, "-chart-right"), chartPlacement === 'right' && chart && statistic), _classNames));

  var chartDom = chart && _jsx("div", {
    className: chartCls,
    children: chart
  });

  var contentCls = classNames("".concat(prefixCls, "-content"), _defineProperty({}, "".concat(prefixCls, "-content-horizontal"), chartPlacement === 'left' || chartPlacement === 'right')); // 默认上下结构

  var contentDom = (chartDom || statisticDom) && (chartPlacement === 'left' ? _jsxs("div", {
    className: contentCls,
    children: [chartDom, statisticDom]
  }) : _jsxs("div", {
    className: contentCls,
    children: [statisticDom, chartDom]
  }));

  var footerDom = footer && _jsx("div", {
    className: "".concat(prefixCls, "-footer"),
    children: footer
  });

  return _jsxs(Card, _objectSpread(_objectSpread({
    className: classString
  }, others), {}, {
    children: [contentDom, children, footerDom]
  }));
};

var Group = function Group(props) {
  return _jsx(StatisticCard, _objectSpread({
    bodyStyle: {
      padding: 0
    }
  }, props));
};

StatisticCard.Statistic = Statistic;
StatisticCard.Divider = Divider;
StatisticCard.Operation = Operation;
StatisticCard.isProCard = true;
StatisticCard.Group = Group;
export default StatisticCard;